<#
	Version 1.00 - Share and Permissions for POS
	Date: 10th January 2015
#>



[int]$xMenuChoiceA = 0
while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 8 ){
Write-host "1. IIS"
Write-host "2. EPISYS-STORES"
Write-host "3. EPISYS-HHT"
Write-host "4. WAS"
Write-host "5. Quit"
[Int]$xMenuChoiceA = read-host "Please enter an option 1 to 5..." }
Switch( $xMenuChoiceA ){
  1{Write-Host Delopying Permission on IIS Nodes -foregroundcolor Black -backgroundcolor Green
	Write-Host -------------------------------------------
		$computers = Get-Content "D:\Powershell\share_computers.txt"
			Invoke-Command -ComputerName $computers {cmd.exe /c net share SOFTWARE /delete /Y}
			Invoke-Command -ComputerName $computers {cmd.exe /c net share Logfiles /delete /Y}
			Invoke-Command -ComputerName $computers {cmd.exe /c net share Pluginlogs /delete /Y}
			Invoke-Command -ComputerName $computers {cmd.exe /c net share Republish /delete /Y}
			Invoke-Command -ComputerName $computers {cmd.exe /c net share IBM /delete /Y}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\Logfiles | Out-Null}
			Invoke-Command -ComputerName $computers {net share SOFTWARE=D:\SOFTWARE "/Grant:IT SRV WEBSPHERE ADMIN,FULL" "/Grant:IT ADM WEBSPHERE ADMIN,FULL"}
			Invoke-Command -ComputerName $computers {cmd.exe /c net share Logfiles=D:\Logfiles "/Grant:everyone,Read"}
			Invoke-Command -ComputerName $computers {cmd.exe /c net share Pluginlogs=D:\IBM\Websphere\Plugins\logs  "/Grant:everyone,Read"}
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls "D:\Logfiles" /grant 'IT SRV WebSphere Admin:(OI)(CI)R'}
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls "D:\IBM\Websphere\Plugins\logs" /grant 'IT DAT Beanstore LOGS:(OI)(CI)R'}
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls "D:\SOFTWARE" /grant 'IT ADM WEBSPHERE ADMIN:(OI)(CI)F'}
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls D:\Software /remove:g balaji.srinivasan /remove:g Sanjay.Jairam /T /Q}
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls D:\Logfiles /remove:g balaji.srinivasan /remove:g Sanjay.Jairam /T /Q}
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls D:\IBM\Websphere\Plugins\logs /remove:g Sanjay.Jairam /remove:g balaji.srinivasan /T /Q}
	}
  2{Write-Host Delopying Permission on Episys Stores Nodes -foregroundcolor Black -backgroundcolor Green
	Write-Host -------------------------------------------
		$computers = Get-Content "D:\Powershell\share_computers.txt"
			Invoke-Command -ComputerName $computers {net share SOFTWARE /delete /Y}
			Invoke-Command -ComputerName $computers {net share Custom01 /delete /Y}
			Invoke-Command -ComputerName $computers {net share Fonts /delete /Y}
			Invoke-Command -ComputerName $computers {net share Images /delete /Y}
			Invoke-Command -ComputerName $computers {net share Logs /delete /Y}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\EPISYS | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\EPISYS\Fonts | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\EPISYS\Images | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\EPISYS\Logs | Out-Null}			
			Invoke-Command -ComputerName $computers {net share SOFTWARE=D:\SOFTWARE "/Grant:IT SRV WEBSPHERE ADMIN,FULL" "/Grant:IT ADM WEBSPHERE ADMIN,FULL"}
			Invoke-Command -ComputerName $computers {net share Custom01=D:\IBM\WebSphere\AppServer\profiles\Custom01 "/Grant:everyone,Read"}
			Invoke-Command -ComputerName $computers {net share Fonts=D:\EPISYS\Fonts "/Grant:Everyone,FULL"}
			Invoke-Command -ComputerName $computers {net share Images=D:\EPISYS\Images "/Grant:Everyone,FULL"}
			Invoke-Command -ComputerName $computers {net share Logs=D:\EPISYS\Logs "/Grant:Everyone,READ"}
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls D:\Software /remove:g Sanjay.Jairam /T /Q}			
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls "D:\SOFTWARE" /grant 'IT ADM WEBSPHERE ADMIN:(OI)(CI)F'}
			# Defect : 7605
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls D:\IBM\WebSphere\AppServer\profiles\Custom01 /remove:g Sanjay.Jairam}								
	}
  3{Write-Host Delopying Permission on Episys HHT Nodes -foregroundcolor Black -backgroundcolor Green
	Write-Host -------------------------------------------
		$computers = Get-Content "D:\Powershell\share_computers.txt"
			Invoke-Command -ComputerName $computers {net share SOFTWARE /delete /Y}
			Invoke-Command -ComputerName $computers {net share Custom01 /delete /Y}
			Invoke-Command -ComputerName $computers {net share HHT_Fonts /delete /Y}
			Invoke-Command -ComputerName $computers {net share HHT_Images /delete /Y}
			Invoke-Command -ComputerName $computers {net share HHT_Logs /delete /Y}
			Invoke-Command -ComputerName $computers {net share WS_Fonts /delete /Y}
			Invoke-Command -ComputerName $computers {net share WS_Images /delete /Y}
			Invoke-Command -ComputerName $computers {net share WS_Logs /delete /Y}
			
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\HHT | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\HHT\Fonts | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\HHT\Images | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\HHT\Logs | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\WebService | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\WebService\Fonts | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\WebService\Images | Out-Null}
			Invoke-Command -ComputerName $computers {New-Item -Type directory D:\WebService\Logs | Out-Null}
			
			Invoke-Command -ComputerName $computers {net share HHT_Fonts=D:\HHT\Fonts "/Grant:Everyone,FULL"}
			Invoke-Command -ComputerName $computers {net share HHT_Images=D:\HHT\Images "/Grant:Everyone,FULL"}
			Invoke-Command -ComputerName $computers {net share HHT_Logs=D:\HHT\Logs "/Grant:Everyone,FULL"}
			
			Invoke-Command -ComputerName $computers {net share WS_Fonts=D:\WebService\Fonts "/Grant:Everyone,FULL"}
			Invoke-Command -ComputerName $computers {net share WS_Images=D:\WebService\Images "/Grant:Everyone,FULL"}
			Invoke-Command -ComputerName $computers {net share WS_Logs=D:\WebService\Logs "/Grant:Everyone,FULL"}						
			Invoke-Command -ComputerName $computers {net share Custom01=D:\IBM\WebSphere\AppServer\profiles\Custom01 "/Grant:Everyone,Read"}
			
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls D:\IBM\WebSphere\AppServer\profiles\Custom01 /remove:g Sanjay.Jairam /remove:g balaji.srinivasan /T /Q}
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls D:\Software /remove:g balaji.srinivasan /remove:g Sanjay.Jairam /T /Q}			
	}
  4{Write-Host Delopying Permission on WAS Nodes -foregroundcolor Black -backgroundcolor Green
	Write-Host -------------------------------------------
		$computers = Get-Content "D:\Powershell\share_computers.txt"
			Invoke-Command -ComputerName $computers {net share SOFTWARE /delete /Y}			
			Invoke-Command -ComputerName $computers {net share IBM /delete /Y}
			Invoke-Command -ComputerName $computers {net share Custom01 /delete /Y}
			Invoke-Command -ComputerName $computers {net share SOFTWARE=D:\SOFTWARE "/Grant:IT SRV WEBSPHERE ADMIN,Full" "/Grant:IT ADM WEBSPHERE ADMIN,Full"}
			Invoke-Command -ComputerName $computers {net share DMGR=D:\IBM\WebSphere\AppServer\profiles\DMGR_ST1 "/Grant:Everyone,Read"}
			Invoke-Command -ComputerName $computers {cmd.exe /c icacls "D:\SOFTWARE" /grant 'IT ADM WEBSPHERE ADMIN:(OI)(CI)F'}
	}
default{<#run a default action or call a function here #>}
}